package com.company.common.exception;

public class ScorpioServiceException extends RuntimeException{
	private static final long serialVersionUID = -1475307749664082663L;

	private int code;

	private String message;

	private boolean isPrintStackTrace = true;// 默认打印 true

	private ScorpioServiceException()
	{

	}

	public ScorpioServiceException(ErrorCode e)
	{
		this.code = e.getCode();
		this.message = e.getMessage();
	}

	public ScorpioServiceException(int code,String message)
	{
		this.code = code;
		this.message = message;
	}

	public ScorpioServiceException(int code,String message,boolean isPrintStackTrace)
	{
		this.code = code;
		this.message = message;
		this.isPrintStackTrace = isPrintStackTrace;
	}

	public boolean isPrintStackTrace() {
		return isPrintStackTrace;
	}

	public void setPrintStackTrace(boolean printStackTrace) {
		isPrintStackTrace = printStackTrace;
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	@Override
	public String toString()
	{
		return "{" +
				"\"code\":" + code +
				", \"message\":\"" + message + "\"" +"}";
	}

}
